# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/5/17 23:42
# @Author   : Robot-Zsj
"""
description:

"""
s = "abcabcbb"
output = 3


def solution(string):
    occ = set()
    n = len(string)
    rk, ans = -1, 0
    for i in range(n):
        if i != 0:
            occ.remove(string[i - 1])
        while rk + 1 < n and string[rk + 1] not in occ:
            occ.add(string[rk + 1])
            rk += 1
        ans = max(ans, rk - i + 1)
    return ans


res = solution(s)
print(res)
assert res == output, "答案错误"
